package com.kantboot.business.talent.repository;

import com.kantboot.user.account.domain.entity.UserAccount;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface BusTalentUserAccountRepository extends JpaRepository<UserAccount, Long> {

    /**
     * 将当前技能等级和当前技能等级开始时间设为空
     */
    @Transactional
    @Modifying
    @Query("update UserAccount set currentSkillLevelId = null, gmtCurrentSkillLevelStart = null where id = ?1")
    void toNullCurrentSkill(Long userAccountId);

    /**
     * 将当前职称等级和当前职称等级开始时间设为空
     */
    @Transactional
    @Modifying
    @Query("update UserAccount set currentTitleLevelId = null, gmtCurrentTitleLevelStart = null where id = ?1")
    void toNullCurrentTitle(Long userAccountId);

    /**
     * 将当前专家人才等级和当前专家人才等级开始时间设为空
     */
    @Transactional
    @Modifying
    @Query("update UserAccount set currentExpertLevelId = null, gmtCurrentExpertLevelStart = null where id = ?1")
    void toNullCurrentExpert(Long userAccountId);

}
